package com.string.demo;

import java.util.Scanner;

public class StringLoginDemo {

    public static void main(String[] args) {

        String username = "admin";
        String password = "123456";

        for (int i = 0; i <3; i++) {
            Scanner sc = new Scanner(System.in);

            System.out.println("请输入用户名");

//            String name = sc.nextLine();
            String name = sc.nextLine();

            System.out.println("请输入密码");

            String pwd = sc.nextLine();
            if (name.equals(username) && pwd.equals(password)) {
                System.out.println("登录成功");
                break;
            }else{
                if (i==2){
                    System.out.println("操作失败频率过多，请与后台管理员联系");
//                    break;

                }else {
                    System.out.println("你还有" +  (2-i) +"次机会");
                }
            }
        }


    }
}
